﻿package com.admin.controller;

import java.util.List;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.common.BaseController;
import com.entity.ProductCategory;
import com.service.ProductCategoryService;

@Controller
@RequestMapping("/admin/product")
public class AdminProductCatoryController extends BaseController {
	@Autowired
	private ProductCategoryService productCategryService;
	@RequestMapping("/list-cate")
	public String listCategory(HttpServletResponse response){
		JSONArray array = new JSONArray();
		List<ProductCategory> list = this.productCategryService.findAllCategory();
		for(ProductCategory category:list){
			JSONObject obj = new JSONObject();
			obj.put("id", category.getId());
			obj.put("text", category.getCategoryName());
			obj.put("state", "open");
			array.add(obj);
		}
		this.outJson(array.toJSONString(), response);
		return null;
	}
}
